{
 "cells": [
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "7a7d09df-a1f5-45f4-b595-a8079b0a9f1f",
   "metadata": {},
   "source": [
    "\n",
    "_Datapane Reports_ are data-centric documents which you can generate using Python. You can think of them as replacements for sending a PDF or PowerPoint, and they can be exported as standalone HTML files and sent over Slack or Email. Reports are often created programmatically from inside other platforms, such as a data pipelines (_\"LightGBM training results v230\"_), CI, or generated on a cadence (_\"Monday's sales forecast\"_).\n",
    "\n",
    "!!! tip\n",
    "    Generating a Report is somewhat similar to generating static-site generator for HTML, like `Hugo` or `Jekyll`\n",
    "\n",
    "Datapane Reports provide the fastest way to share with others, for instance:\n",
    "\n",
    "- Export as a standalone HTML file (with all it's assets inline) which you can share on Slack or Email\n",
    "- Host on GitHub Pages or S3 for a public presentation\n",
    "- Embed within your own internal applications \n",
    "\n",
    "## Example\n",
    "\n",
    "The example below builds upon the example in the previous section, comprised of a heading, figure, interactive figure, and interactive data table. \n",
    "\n",
    "Datapane makes it simple to convert this into a Report, as per the examples below (see the [API reference](../reference/reports.md) for further details)."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7e75873a-7dbe-4554-82f8-ed77a8c26499",
   "metadata": {
    "tags": [
     "remove_all_output"
    ]
   },
   "outputs": [],
   "source": [
    "import altair as alt\n",
    "import datapane as dp\n",
    "from vega_datasets import data\n",
    "\n",
    "df = data.iris()\n",
    "\n",
    "fig = (\n",
    "    alt.Chart(df)\n",
    "    .mark_point()\n",
    "    .encode(x=\"petalLength\", y=\"petalWidth\", color=\"species\")\n",
    ")\n",
    "\n",
    "view = dp.Blocks(\"# My report\", dp.Plot(fig), dp.DataTable(df))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1ce16750-15a9-41f1-8ae4-c3a3ac7796e0",
   "metadata": {
    "tags": [
     "remove_input",
     "remove_all_output"
    ]
   },
   "outputs": [],
   "source": [
    "dp.save_report(view, path=\"my_report.html\")"
   ]
  },
  {
   "attachments": {},
   "cell_type": "markdown",
   "id": "d881362e",
   "metadata": {},
   "source": [
    "## Saving Reports\n",
    "\n",
    "Reports can be saved / exported as standalone files which can be shared without a server. All data and plots are encapsulated in a single HTML file, which provides a secure and low-barrier sharing method. Views can be exported as a standalone report using [dp.save_report][datapane.processors.api.save_report]:\n",
    "\n",
    "```python\n",
    "# save as a static HTML-based report\n",
    "dp.save_report(view, path=\"my_report.html\")\n",
    "```\n",
    "\n",
    "You can [view the saved report](./my_report.html){:target=_blank}, [download it](./my_report.html){:download=my_report.html}, open it locally, or send via email and slack.\n",
    "\n",
    "!!! note\n",
    "    Although standalone and serverless, Internet access is required to retrieve Datapane front-end libraries needed to render the report\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
